home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 475 < prev    next >
Encoding:
Text File  |  1996-08-05  |  705 b   |  27 lines

  1. Path: es.rice.edu!joel
  2. From: joel@rice.edu (Joel Castellanos)
  3. Newsgroups: comp.lang.c++
  4. Subject: Q: Visual C++ rand
  5. Date: 4 Jan 1996 18:55:57 GMT
  6. Organization: Rice University, Houston, Texas
  7. Message-ID: <4ch7rt$aeu@larry.rice.edu>
  8. NNTP-Posting-Host: moe.rice.edu
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. I am trying to use the rand function in Visual C++
  12. The help file says it is:
  13.    int rand( void );
  14. Yet the following program gives me the compile error:
  15.    error C2446: '=' : no conversion from 'int(__cdecl *)(void)' to 'int'
  16.  
  17. rand should be returning an int - so why the conversion error?
  18.  
  19. #include <stdio.h>
  20. #include <math.h>
  21. #include <stdlib.h> 
  22. void main () {
  23. int n;
  24. n= rand;
  25. printf("n = %d\n", n);
  26. }
  27.